package com.arancia.codinglife.service;

import com.arancia.codinglife.dao.TelephoneDao;
import com.arancia.codinglife.entity.Telephone;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional
public class TelephoneService {
	@Autowired
	private TelephoneDao telephoneDao;

	public void addTelephone(Telephone telephone) {
		telephoneDao.save(telephone);
	}

	public void deleteTelephoneById(Long id) {
		telephoneDao.deleteById(id);
	}

	public List<Telephone> findAll() {
		return telephoneDao.findAll();
	}

	public Telephone findTelephoneById(Long id) {
		return telephoneDao.findById(id).get();
	}

	public List<Telephone> findTelephoneByCo(String co) {
		return telephoneDao.findByCo(co);
	}
}
